Revisiting the Inverted Pendulum on a Moving Cart

نویسنده

  • Spyros Andreou
چکیده

Many control engineers found the inverted pendulum on a moving cart very interesting and intriguing because many control principles can be shown. Two examples are to balance a stick on the end of one’s finger and the other one is to balance a rocket during liftoff. This is a highly non-linear system but for simplicity purposes the overall system is linearized making some assumptions. Therefore, in this paper linear first-order differential equations will be utilized for modeling the system along with the MATLAB (MATrixLABoratory) software for simulation purposes. Finally, the same MATLAB simulations will demonstrate stabilization of such system using its ACKER and LSIM built-in functions. The vigorous mathematical theory of this project is presented using the Lagrange’s method along with some basic knowledge in Linear Algebra and Differential Equations due to simulations. Introduction This work discusses a mathematical model of an inverted pendulum on a moving cart, a common toy control system. Many control engineers found this system interesting and intriguing because many control principles can be shown. Note that this is the same problem as balancing a stick on the end of one’s finger. At first glance this might not be exciting; however, one may note that it is also related to the problem of balancing a rocket during liftoff which is a more exciting problem to tackle. The same issues are discussed, as in the biological systems, that is, modeling, mathematical analysis and stability analysis. The resulting model is a non-linear and highly unstable system. It is also a notoriously difficult system for which to design a good controller. Thus, there were a lot of efforts in finding various methods to stabilize such a difficult system. One simple method that stabilizes this system by approximating the non-linear model with the linear model is presented in this report. A description of the system is given followed by a brief introduction of the Lagrange’s method [1] for modeling the system. The mathematical analysis (finding steady states, linearization, etc.) is also presented. Finally, the pole placement using state-variable feedback method is introduced along with Ackerman’s formula to stabilize the pendulum. Moreover, the performance of the design is tested by simulating the system using the computer software MATLAB [2]. The reader may obtain a more theoretical perspective from references [3] and [4]. A very brief reference can also be found in [5]. Description The setup of this system is shown in the following figure [1]: European International Journal of Science and Technology ISSN: 2304-9693 www.eijst.org.uk 8 Figure 1: Inverted pendulum on as Moving Cart The system consists of a cart of mass M that slides in one dimension y on a horizontal surface, with a ball of mass m at the end of a rigid massless pendulum of length l. The cart and the ball are treated as point masses, with the pivot at the center of the cart. There is assumed to be no friction and no air resistance. It is shown as input a horizontal force f. The other signals shown are the angle θ and the position of the ball with coordinates (y2, z2) which are y2 = y + lsin(θ) and z2 = l cos(θ). Modeling The derivation of the equations governing the motion of this system is based on the method developed by the eighteenth-century French mathematician Lagrange. The differential equations that result from this method are known as Lagrange’s equations derived from Newton’s laws of motion. The fundamental principle of Lagrange’s equations is the representation of the system by a set of generalized coordinates qi(i = 1 ,2, 3,.... r), one for each independent degree of freedom of the system, completely incorporating the constraints unique to the system. After having defined the generalized coordinates, the kinetic energy T is expressed in terms of these coordinates and their derivatives and the potential energy V is expressed in terms of the generalized coordinates. Next the Lagrangian function L = T(q1, q2,...., qr-1, qr, , ... ... ) – V(q1, q2,...., qr-1, qr) is formed. And finally the desired equations of motion are defined using the Lagrange’s equations − = for i = 1, 2, 3, .....r where Qi denotes generalized forces (forces and torques) that are external to the system. Each of the differential equations in the set will be a second-order differential equation, so a dynamic system with r degrees of freedom is represented by r second-order differential equations. If one state variable is assigned to each generalized coordinate and another to the corresponding derivative, we end up with 2r equations. So, a system with r degrees of freedom is of order 2r. A typical application of Lagrange’s equations is to define the motion of a collection of bodies that are connected together in some manner such as our system. The motion of the system is uniquely defined by the displacement of the cart from some reference point and the angle that the pendulum rod makes with respect to the vertical axis. So, it can be concluded that the system has only two degrees of freedom, and that the dynamics must be expressed in terms of the corresponding generalized coordinates chosen (y, θ). The details of the derivation of the exact equations of motion are given in [3]. The equations are( + ) + ( − ( sin( = $and ( + − % &'( = 0where g = 9.81 m/sec, the acceleration due to gravity. European International Journal of Science and Technology Vol. 2 No. 7 September 2013 9 Analysis The two previous equations are nonlinear owing to the presence of the trigonometric terms sin(θ) and cos(θ) and the quadratic terms ( and . If the pendulum is stabilized; however, then θ is kept small. This justifies the approximation cos(θ) ≈1 and sin(θ) ≈ θ. It can also be assumed that *'+ are kept small so that the quadratic terms are negligible. Another way to observe this is to linearize the above equations about an equilibrium position, of which there are two: (y, θ) = (0, 0) and (y, θ) = (0, π); that is, the pendulum is either up or down. The first case is considered because is more interesting. Thus, the linearized model is as follows: (M + m) + = $and + − % = 0 . Defining the state vector x = [y, θ, , ]where T denotes transpose, the statespace representation (standard matrix form) of the linearized system can be found. The state-variables are the cart position, rod angle, cart velocity and rod angular velocity. The linearized model consists of four first-order differential equations as follows: , = , = , ( = = . / − 01 / and 2 3 = = − . /4 + (/50 1 /4 . All these equations can be out into a standard matrix form 6 = 76 + 89 where A = :;; ;<0 0 1 0 0 0 0 1 0 >01 / 0 0 0 (/50 1 /4 0 0?@ @@A and B = :;; ;< 00 / > /4?@ @@A and u = f = external force. Having converted the system to the statespace representation, it is ready for stability analysis as well as for performance analysis by simulation. Certain numerical values are selected which are: M = 5 kg (mass of cart), m = 0.5 kg (mass of pendulum), l = 1 m (length of pendulum, and g = 9.81 m/sec 2 (acceleration due to gravity). Stability Analysis With the numerical values the following system is obtained: 6 = B0 0 1 0 0 0 0 1 0 −0.98 0 0 0 10.78 0 0F 6 + B 00 0.2 −0.2F 9 To gain some insight on the system, its open-loop poles are determined to be at 0, 0, 3.283, and -3.283. The poles at ±3.283 arise from the angle subsystem and are involved with θ and . The two poles at zero evolve from the Newton’s system relating to the horizontal position and involve y and . Now let us use the state feedback law u= Kx to stabilize the system where K is the feedback gain. Using this method, the rod angle should be measured, the rod angular velocity, the cart position and the cart velocity. To accomplish this, one way is to place potentiometers at the rod pivot point for the rod angle and on one wheel for the cart position. To measure the rod angular velocity and the cart velocity, it is necessary to place tachometers at the rod pivot point and on the other wheel. This involves much instrumentation and the apparatus might be complicated to be built. There are other designs such as output feedback control system where only the output need to be measured, namely the rod angle and the cart position. This is beyond the scope of this paper. Now the purpose is to evaluate K using Ackermann’s formula given by K = HIJKI> ∆(A) where Un is the reachability matrix given by Un = [B AB A 2 B .... A n-1 B] and HIJ = [0 0 ... 0 1] is the last row of the n x n identity matrix. ∆(A) is the desired characteristic polynomial evaluated at A. It is an n x n matrix polynomial. Since out system is a fourth order, n = 4. So, the control law has the form u = -K x = European International Journal of Science and Technology ISSN: 2304-9693 www.eijst.org.uk 10 [k1 k2 k3 k4] x.The desired closed-loop poles are selected to be s = -1 ± i and s = -2 ± 2i. This yields the desired characteristic polynomial of ∆ D (s) = s 4 + 6s 3 +18s 2 + 24s + 16 and the 4 x 4 matrix polynomial is given by ∆ D (A) = A 4 + 6A 3 +18A 2 + 24A + 16I. The reachability matrix is U4 = [ B AB A 2 B A 3 B]. The following MATLAB code is written %here is the inverted pendulum on a cart A matrix A=[0 0 1 0;0 0 0 1;0 -0.98 0 0;0 10.78 0 0]; %this is the B matrix B=[0;0;0.2;-0.2]; %eigenvalues of A b=eig(A) %the pole placement matrix P is P=[-1+i;-1-i;-2+2i;-2-2i]; %the gains k1 k2 k3 and k4 are given by K=acker(A,B,P) %the closed loop A1 matrix is given by A1=A-B*K; %plotting %initial conditions x0=[0.1 0.1 0 0]; %matrices to use the lsim function B1=[0;0;0;0];C1=[0 0 0 0];D1=0; closedloopsystem=ss(A1,B1,C1,D1); t=[0:0.01:18]; %input u is zero too u=0*t; %here is the lsim function [y,T,x]=lsim(closedloopsystem,u,t,x0); plot(T,x(:,1),T,x(:,2),'--') xlabel('time in seconds') ylabel('cart position & rod angle theta') title('Inverted Pendulum Closed Loop Response') Figure 2. Simulation code for the inverted pendulum on a moving cart The MATLAB command acker gave the following gain numerical values K = [-8.1633 -152.0633 -12.2449 -42.2449]. The initial conditions of the simulation at t = 0 are rod angle θ(t) = 0.1 rad, cart position y(t) = 0.1 m, rod angular velocity  (t) = 0 rad/s and cart velocity (t) = 0 m/s. The simulation graph is shown is the Figure 3. European International Journal of Science and Technology Vol. 2 No. 7 September 2013 11 Figure3. Closed loop response; Rod angle (--) & Cart position. It can be seen that after about 6 seconds the system comes to rest with the rod balanced at θ = 0 and the cart at the position y = 0. The rod response θ(t) is quite good, and it remains small so that the linear approximation holds. However, the position y(t) increases to 0.43 m before it returns to zero. This is necessary since the cart must run up under the rod to balance it before coming back to the origin y = 0. Another simulation: Using now initial conditions of x0 = [0 0 0.1 0.1] the following simulation graph is obtained. Figure 4. Rod angular velocity (--) and cart velocity. It can also be seen that after about 6 seconds the system comes to rest with the rod angular velocity balanced at = 0 and the cart velocity at = 0. Pole-placement design using full state feedback is sometimes unsuitable, since it does not take advantage of the full design freedom in a problem. The overall performance can be further improved by using output feedback design where the zeros of the transfer function from u(t) to y(t) and from u(t) to θ(t) are manipulated. In the pole-placement method zeros are not used which is the main drawback of the method. Only poles of the desired characteristic polynomial are used. 0 2 4 6 8 10 12 14 16 18 -0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 time in seconds c a rt p o s it io n & r o d a n g le t h e ta Inverted Pendulum Closed Loop Response 0 2 4 6 8 10 12 14 16 18 -0.15 -0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25 0.3 time in seconds c a rt v e lo c it y & r o d a n g u la r v e lo c it y Inverted Pendulum Closed Loop Response European International Journal of Science and Technology ISSN: 2304-9693 www.eijst.org.uk 12 Conclusion The modeling of a very difficult control system was demonstrated using the Lagrange’s method which is an effective method in deriving the equations of motion. By linearizing the system around the origin (0,0) where the pendulum is up, a very good approximation was obtained to the actual nonlinear system. Obtaining the linearized model, a stabilizing controller was designed using pole-placement with statevariable feedback along with the Ackermann’s formula. This method has some drawbacks which can be improved by using a different method. Overall, the modeling of such a difficult system was meaningful and successful as indicated by the simulation results of the linearized approximation. It can be used as a sample for modeling more applicable interesting systems which can help for the advancement of today’s technology. References: [1] B. Friedland, Control System Design – An introduction to State –Space methods, McGraw-Hill Inc., New York, 1986. [2] W. J. Palm, A Concise Introduction to MATLAB, McGraw-Hill Inc. New York, 2008. [3] J. C. Doyle, B. A. Francis, A. R. Tannenbaum, Feedback Control Theory, Macmillan Publishing Company, New York, 1992. [4] F. L. Lewis, Applied Optimal Control & Estimation, Prentice Hall, Englewood Cliffs, New Jersey, 1992. [5] Richard R. Dorf& Robert H. Bishop, Modern Control Systems, 12 th edition, Pearson, New Jersey, 2010.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Neural Network Control of an Inverted Pendulum on a Cart

The balancing of an inverted pendulum by moving a cart along a horizontal track is a classic problem in the area of control. This paper describes two Neural Network controllers to swing a pendulum attached to a cart from an initial downwards position to an upright position and maintain that state. Both controllers are able to learn the demonstrated behavior which was swinging up and balancing t...

متن کامل

Inverted Pendulum Stabilization Via a Pyragas-Type Controller: Revisiting the Triple Zero Singularity

The use of Pyragas-Type controller proved interest in the stabilization of unstable periodic orbits. The stabilization problem of a balancing inverted pendulum on an horizontally moving cart by the use of such a controller is considered. The main objective of the paper is to propose delayed control law containing only proportional gains able to stabilize the inverted pendulum by avoiding the ex...

متن کامل

Application of Neural Networks for Control of Inverted Pendulum

The balancing of an inverted pendulum by moving a cart along a horizontal track is a classic problem in the area of automatic control. In this paper two Neural Network controllers to swing a pendulum attached to a cart from an initial downwards position to an upright position and maintain that state are described. Both controllers are able to learn the demonstrated behavior which was swinging u...

متن کامل

On the Inverted Pendulum on a Cart Moving along an Arbitrary Path

This article discusses a problem of stabilization for an inverted pendulum on a cart. In this work the cart does not travel along an horizontal line, which is the case commonly considered in the literature, but along an arbitrary path in the horizontalvertical plane. The main obstacle encountered lies in the fact that the feedback controlled system becomes unstable in some ”critical regions” al...

متن کامل

Second Order Sliding Mode Control of Underactuated Mechanical Systems II: Orbital Stabilization of an Inverted Pendulum with Application to Swing Up/Balancing Control

Orbital stabilization of an underactuated cart-pendulum system is under study. The quasihomogeneous control synthesis is utilized to design a second order sliding mode controller that drives the actuated cart to a periodic reference orbit in finite time, while the non-actuated pendulum produces bounded oscillations. A modified Van der Pol oscillator is introduced into the synthesis as an asympt...

متن کامل

Control of an Inverted Pendulum

The balancing of an inverted pendulum by moving a cart along a horizontal track is a classic problem in the area of control. This paper will describe two methods to swing a pendulum attached to a cart from an initial downwards position to an upright position and maintain that state. A nonlinear heuristic controller and an energy controller have been implemented in order to swing the pendulum to...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2013